#!/usr/bin/python3.4
# -*- coding=utf-8 -*-

import nmap
import sys
def nmap_ping_scan(network_prefix):
    nm = nmap.PortScanner()
	ping_scan_raw_result = nm.scan(hosts=network_prefix, arguments='-v -n -sn')

	host_list = []
	for IP in ping_scan_raw_result['scan']:
		if ping_scan_raw_result['scan'][IP]['status']['state'] == 'up':
			host_list.append(ping_scan_raw_result['scan'][IP]['addresses']['ipv4'])
			#print( '%-20s %5s' % (ping_scan_raw_result['scan'][IP]['addresses']['ipv4'],'is UP'))
	return host_list

if __name__ == '__main__':
	for host in nmap_ping_scan(sys.argv[1]):
		print( '%-20s %5s' % (host,'is UP'))

#################################################################
#[root@Fedora python]# ./nmap_ping_scan.py 172.16.1.0/24
#172.16.1.104         is UP
#172.16.1.101         is UP
#172.16.1.103         is UP
#172.16.1.102         is UP
#172.16.1.107         is UP
#172.16.1.254         is UP
#172.16.1.15          is UP
#172.16.1.12          is UP